<template>
  <div>
    <!-- 展厅接待 -->
    <div class="duty">今日预约进店：{{ todayInvite }} 已进店：{{ arrived }} 首次客流：{{ fastGoShoup }} 客流总数：{{ sumGoShoup }}</div>
    <TopFilter :list="topFilterList" :cols="3" labelWidth="100" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>

    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)"
      columnsRef="potenCus_customer_exhibition_index_01"
    >
      <template slot="controls" slot-scope="props">
        <!-- <el-button size="small" type="primary" icon="el-icon-plus" @click="addHandle">新增客流</el-button> -->
        <multiuse-button size="small" type="primary" :click="addHandle" :auth-list="auths" auth-mark="/api/cyxdms.clue/receptionist/saveReceptionist">新增客流</multiuse-button>
        <!-- <el-button size="small" type="primary" icon="el-icon-plus" @click="exportHandle">导出</el-button> -->
        <multiuse-button size="small" type="primary" :click="exportHandle" :auth-list="auths" auth-mark="/api/cyxdms.retail/ordermanage/salesOrders/export/excel">导出</multiuse-button>
      </template>
    </FilterTable>
    <el-dialog :visible.sync="visible" :title="title" width="60%">
      <modal v-if="visible" :type="handleType" :RolePosition="RolePosition" :rowData="formData" @close="closeHandler" />
    </el-dialog>

    <Drawer :visible.sync="isShow" :title="title" :width="1000" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <!-- <Detail :type="handleType" :rowData="formDataDetail" @close="closeHandler" /> -->
      <cluesModel v-if="isShow" type="exhibitionAdd" :RolePosition="RolePosition" :rowData="formData" @fatherClose="fatherClose" @close="closeHandler" />
    </Drawer>
    <!-- 潜客跟进 -->
    <BaseDialog :visible.sync="followVisible" title="潜客跟进" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <followModal :type="handleType" :rowData="formData" @close="closeHandler_follow" />
    </BaseDialog>
  </div>
</template>
<script>
// 获取用户信息
import { queryReceptionistInfo, getUsersByPosition, getUserInfo, getTodayInvite, getFastGoShoup, exportFlowList, updateDisposeStatusById } from '@/api/potenCus/customer/exhibition';
import { dictionary } from '@/utils/dictMixin';
import modal from './modal';
import cluesModel from '../../customer/potenCusManage/cluesModel';
import { exportExcelFile } from '@/utils/index';
import { authority } from '@/utils/authMixin';
import followModal from '../customerFollowInfo/tabs/followModal';
export default {
  name: 'quotedprice',
  components: {
    modal,
    cluesModel,
    followModal
  },
  mixins: [dictionary, authority],
  data() {
    let defaultData = '';
    let time = new Date(); //根据时间戳生成的时间对象
    let year = time.getFullYear();
    let month = time.getMonth() + 1;
    let date = time.getDate() > 9 ? time.getDate() : '0' + time.getDate();
    let hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours();
    let minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes();

    defaultData = `${year}-${month > 9 ? month : '0' + month}-${date}`;
    return {
      topFilterList: this.createTopFilters(),
      fetchParams: { arriveDateStart: defaultData, arriveDateEnd: defaultData, receptionConsultant: '' },
      title: '',
      visible: false,
      dialogTitle: '',
      fetchApi: queryReceptionistInfo,
      columns: this.createTableColumns(),
      handleType: '',
      formData: {},
      querInfo: {
        // 请求数据
        customerName: '',
        mobilePhone: '',
        storeType: '',
        arriveDateStart: '',
        arriveDateEnd: '',
        consultantName: '',
        isValid: '',
        flowType: '',
        isFiling: '',
        receptionStatus: ''
      },
      RolePosition: [],
      isShow: false,
      todayInvite: '',
      arrived: '',
      fastGoShoup: '',
      sumGoShoup: '',
      toShopNum: '',
      roleType: localStorage.getItem('roleType'),
      isDisabled: '',
      userId: '',
      followVisible: false,
      initUserId: '',
      roleflag: true
    };
  },
  async created() {
    await getUserInfo().then(res => {
      if (res.resultCode == 200) {
        localStorage
          .getItem('roleType')
          .split(',')
          .forEach(x => {
            if (x == '10061015') {
              this.initUserId = res.data.userInfo.userId;
              this.roleflag = false;
            }
          });
      }
    });
    this.roleType.split(',').forEach(x => {
      if (x == '10061015') {
        this.fetchParams.receptionConsultant = this.initUserId;
      }
    });
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
    this.init();
  },
  methods: {
    createTopFilters() {
      return [
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',
          placeholder: '请输入...'
        },
        {
          type: 'INPUT',
          label: '手机号码',
          fieldName: 'mobilePhone',
          placeholder: '请输入...',
          maxlength: 11
        },
        {
          type: 'SELECT',
          label: '进店方式',
          fieldName: 'storeType',
          placeholder: '请选择...',
          initialValue: '',
          itemList: this.createDictList('7022')
        },
        {
          type: 'RANGE_DATE',
          label: '进店日期',
          fieldName: 'arriveDateStart|arriveDateEnd',
          // dateType:'exactdaterange',
          placeholder: '请选择',
          initialValue: ''
        },
        {
          type: 'SELECT',
          label: '所属顾问',
          fieldName: 'consultantName',
          initialValue: '',
          placeholder: '请选择...',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '是否有效',
          fieldName: 'isValid',
          initialValue: '',
          placeholder: '请选择...',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否首次',
          fieldName: 'flowType',
          initialValue: '',
          placeholder: '请选择...',
          itemList: this.createDictList('7003')
        },
        {
          type: 'SELECT',
          label: '是否建档',
          fieldName: 'isFiling',
          initialValue: '',
          placeholder: '请选择...',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '接待状态',
          fieldName: 'receptionStatus',
          initialValue: '',
          placeholder: '请选择...',
          itemList: [
            { text: '接待中', value: '0' },
            { text: '已接待', value: '1' }
          ]
        },
        {
          type: 'SELECT',
          label: '接待顾问',
          fieldName: 'receptionConsultant',
          initialValue: '',
          placeholder: '请选择...',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '处理状态',
          fieldName: 'disposeStatus',
          initialValue: '',
          placeholder: '请选择...',
          itemList: [
            { text: '未处理', value: '0' },
            { text: '已处理', value: '1' }
          ]
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 200,
          fixed: 'left',
          render: (props, h) => {
            // || props.row.leaveTime?true:false  this.isDisabled == 10061011?true:props.row.potentialCustomerNo?true:props.row.receptionStatus=="接待中"?props.row.isValid == "有效"?false:true:true
            return (
              <div>
                <multiuse-button
                  divider="after"
                  size="mini"
                  disabled={props.row.showEditor == 0 ? true : false || props.row.showEditor == 1 ? false : true || props.row.showEditor == 2 ? false : true}
                  type="text"
                  onClick={() => this.editHandle(props.row)}
                  auth-list={this.auths}
                  auth-mark={'/api/cyxdms.clue/receptionist/updateReceptionById/${id}'}
                >
                  编辑
                </multiuse-button>
                <multiuse-button
                  divider="after"
                  size="mini"
                  disabled={props.row.showRecord == 0 ? true : false}
                  type="text"
                  onClick={() => this.addHandleTable(props.row)}
                  auth-list={this.auths}
                  auth-mark={'/api/cyxdms.clue/potenCus/insertPotenCus'}
                >
                  建档
                </multiuse-button>
                <multiuse-button divider="after" size="mini" disabled={props.row.showRecord == 0 ? true : false} type="text" onClick={() => this.noAddHandleTable(props.row)}>
                  不建档
                </multiuse-button>
                <el-button size="mini" type="text" onClick={() => this.detailHandle(props.row)}>
                  明细
                </el-button>
              </div>
            );
          }
        },
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '接待状态',
          dataIndex: 'receptionStatus',
          align: 'center',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('7020'),
          render: props => {
            return <span>{this.createDictText(Number(props.row.receptionStatus), '7020')}</span>;
          }
        },
        {
          title: '接待顾问',
          // dataIndex: 'receptionConsultant',
          dataIndex: 'receptionConsultantName',
          sorter: true,
          showOverflowTooltip: true,
          filter: true,
          filterType: 'input'
          /* filterType: 'checkbox',
          filterItems: [],
          render: props => {
            let receptionConsultantName=""
            console.log(this.columns[3].filterItems,"this.columns[3].filterItems",props.row.receptionConsultant)
            this.columns[3].filterItems.forEach(x=>{
              if(props.row.receptionConsultant == x.value){
                receptionConsultantName = x.text
              }
            })
            return <span>{receptionConsultantName}</span>;
          } */
        },

        /* {
          title: '是否有效',
          dataIndex: 'isValid',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          // filterItems: this.createDictList('1004'),
          // render: props => {
          //   return <span>{this.createDictText(props.row.isValid, '1004')}</span>;
          // }

        }, */
        {
          title: '接待时长（分钟）',
          dataIndex: 'receptionTimeLength',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        },
        {
          title: '处理状态',
          dataIndex: 'disposeStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          // filterItems: this.createDictList('7022'),
          render: props => {
            return <span>{props.row.disposeStatus == 70681001 ? '未处理' : '已处理'}</span>;
          }
        },

        {
          title: '是否建档',
          dataIndex: 'isFiling',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.isFiling, '1004')}</span>;
          }
        },

        {
          title: '是否首次',
          dataIndex: 'passengerFlowType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('7003'),
          render: props => {
            return <span>{this.createDictText(props.row.passengerFlowType, '7003')}</span>;
          }
        },
        {
          title: '进店方式',
          dataIndex: 'storeType',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('7022'),
          render: props => {
            return <span>{this.createDictText(props.row.storeType, '7022')}</span>;
          }
        },
        {
          title: '客户编号',
          dataIndex: 'potentialCustomerNo',
          sorter: true,
          showOverflowTooltip: true,
          filter: true,
          width: 140,
          filterType: 'input'
        },
        {
          title: '客户名称',
          dataIndex: 'customerName',
          sorter: true,
          showOverflowTooltip: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '性别',
          dataIndex: 'gender',
          align: 'center',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1002'),
          render: props => {
            return <span>{this.createDictText(props.row.gender, '1002')}</span>;
          }
        },
        {
          title: '手机号码',
          dataIndex: 'mobilePhone',
          sorter: true,
          showOverflowTooltip: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '进店时间',
          dataIndex: 'arriveDate',
          sorter: true,
          filter: true,
          align: 'center',
          showOverflowTooltip: true,
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd hh:mm',
          render: props => {
            let fullDate = '';
            if (props.row.arriveDate != null) {
              let arriveDateNum = Number(props.row.arriveDate);
              let time = new Date(arriveDateNum); //根据时间戳生成的时间对象
              let year = time.getFullYear();
              let month = time.getMonth() + 1;
              let date = time.getDate() > 9 ? time.getDate() : '0' + time.getDate();
              let hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours();
              let minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes();
              fullDate = `${year}-${month}-${date} ${hours}:${minutes}`;
            }

            return <span>{fullDate}</span>;
          }
        },
        {
          title: '离店时间',
          dataIndex: 'leaveTime',
          hidd: this.roleflag, //销售顾问可以编辑离店时间
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          align: 'center',
          filterType: 'date-range',
          dateFormat: 'yyyy-MM-dd hh:mm',
          render: props => {
            let fullDate = '';
            if (props.row.leaveTime != null) {
              let leaveTimeNum = Number(props.row.leaveTime);
              let time = new Date(leaveTimeNum); //根据时间戳生成的时间对象
              let year = time.getFullYear();
              let month = time.getMonth() + 1;
              let date = time.getDate() > 9 ? time.getDate() : '0' + time.getDate();
              let hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours();
              let minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes();
              fullDate = `${year}-${month}-${date} ${hours}:${minutes}`;
            }
            return <span>{fullDate}</span>;
          }
        },

        {
          title: '进店人数',
          dataIndex: 'arrivePeopleNum',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        },
        {
          title: '当前进店次数',
          dataIndex: 'toShopNum',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        }
        /* {
          title: '所属顾问',
          dataIndex: 'consultantName',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        }, */
        /* {
          title: '车系',
          dataIndex: 'series',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        },
        {
          title: '车型',
          dataIndex: 'model',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        },
        {
          title: '配置',
          dataIndex: 'packages',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        }, */
        /* {
          title: '备注',
          dataIndex: 'remark',
          sorter: true,
          filter: true,
          align: 'center',
          filterType: 'input'
        } */
      ];
    },
    async reload() {
      getTodayInvite().then(res => {
        this.todayInvite = res.data.todayInvite;
        this.arrived = res.data.arrived;
      }),
        getFastGoShoup().then(res => {
          this.fastGoShoup = res.data.fastGoShoup;
          this.sumGoShoup = res.data.sumGoShoup;
          this.toShopNum = res.data.toShopNum;
        });
    },

    async init() {
      let fullDate = '';
      let time = new Date(); //根据时间戳生成的时间对象
      let year = time.getFullYear();
      let month = time.getMonth() + 1;

      //===========   CMS   添加月份前面补0    开始===========
      month = month > 9 ? month : '0' + month;
      //===========   CMS   添加月份前面补0    结束===========

      let date = time.getDate() > 9 ? time.getDate() : '0' + time.getDate();
      let hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours();
      let minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes();
      let seconds = time.getSeconds() > 9 ? time.getSeconds() : '0' + time.getSeconds();
      fullDate = `${year}-${month}-${date}`;
      // this.topFilterList[3].initialValue = [fullDate, fullDate];
      this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue = [fullDate, fullDate];
      console.log(this.columns, 'columns');
      getTodayInvite().then(res => {
        this.todayInvite = res.data.todayInvite;
        this.arrived = res.data.arrived;
      }),
        getFastGoShoup().then(res => {
          this.fastGoShoup = res.data.fastGoShoup;
          this.sumGoShoup = res.data.sumGoShoup;
          this.toShopNum = res.data.toShopNum;
        }),
        // 查询所属顾问
        await getUserInfo().then(res => {
          if (res.resultCode == 200) {
            this.userId = res.data.userInfo.userId;
            let param = {
              // companyId:res.data.userInfo.companyId,
              menuId: 2020351,
              positionCodes: '10061015'
            };
            getUsersByPosition(param).then(res => {
              if (res.resultCode == 200) {
                this.RolePosition = res.data.map(x => ({ value: x.userId, text: x.userName, orgId: x.orgId }));
                // this.RolePosition=_.uniqBy(this.RolePosition,'value')
                // console.log(this.RolePosition,this.columns,"this.RolePosition",this.topFilterList)
                this.topFilterList[4].itemList = this.RolePosition;
                this.topFilterList[9].itemList = this.RolePosition;
                this.columns[3].filterItems = this.RolePosition;
                // this.topFilterList[4].itemList = this.RolePosition;
                // this.topFilterList.find(x => x.fieldName === 'consultantName').itemList = this.RolePosition;
              } /* else{
                this.$message.error('获取人员列表失败!');
              } */
            });
          } else {
            this.$message.error('获取当前登录用户信息失败!');
          }
        });
      console.log(this.userId, this.roleType.split(','), 'this.userId');
      // 判断是前台接待还是展厅顾问
      this.roleType.split(',').forEach(x => {
        console.log(x, 'this.x');
        if (x == '10061011') {
          //前台接待consultant
          this.isDisabled = x;
          // this.topFilterList.find(item => item.fieldName === 'consultant').initialValue=''
          // this.topFilterList[4].initialValue = '';
          this.topFilterList.find(item => item.fieldName === 'receptionConsultant').initialValue = '';
        }
        if (x == '10061015') {
          //展厅顾问
          this.isDisabled = x;
          // this.topFilterList[4].initialValue = this.userId;
          this.topFilterList.find(item => item.fieldName === 'receptionConsultant').initialValue = this.userId;
        }
        if (x == 'null') {
          this.isDisabled = x;
          this.topFilterList.find(item => item.fieldName === 'receptionConsultant').initialValue = '';
          // 20191206 this.topFilterList.find(item => item.fieldName === 'consultant').initialValue = '';
        }
      });
      this.fetchParams.receptionConsultant = this.topFilterList.find(item => item.fieldName === 'receptionConsultant').initialValue;
    },
    //新增客流
    addHandle() {
      this.handleType = 'add';
      this.title = '客流登记';
      this.visible = true;
    },
    //导出
    async exportHandle() {
      this.querInfo.customerName = this.topFilterList.find(item => item.fieldName === 'customerName').initialValue
        ? this.topFilterList.find(item => item.fieldName === 'customerName').initialValue
        : '';
      this.querInfo.mobilePhone = this.topFilterList.find(item => item.fieldName === 'mobilePhone').initialValue ? this.topFilterList.find(item => item.fieldName === 'mobilePhone').initialValue : '';
      this.querInfo.storeType = this.topFilterList.find(item => item.fieldName === 'storeType').initialValue ? this.topFilterList.find(item => item.fieldName === 'storeType').initialValue : '';
      this.querInfo.arriveDateStart = this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[0]
        ? this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[0].slice(0, 10)
        : '';
      this.querInfo.arriveDateEnd = this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[1]
        ? this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[1].slice(0, 10)
        : '';
      this.querInfo.consultantName = this.topFilterList.find(item => item.fieldName === 'consultantName').initialValue
        ? this.topFilterList.find(item => item.fieldName === 'consultantName').initialValue
        : '';
      this.querInfo.isValid = this.topFilterList.find(item => item.fieldName === 'isValid').initialValue ? this.topFilterList.find(item => item.fieldName === 'isValid').initialValue : '';
      this.querInfo.flowType = this.topFilterList.find(item => item.fieldName === 'flowType').initialValue ? this.topFilterList.find(item => item.fieldName === 'flowType').initialValue : '';
      this.querInfo.isFiling = this.topFilterList.find(item => item.fieldName === 'isFiling').initialValue ? this.topFilterList.find(item => item.fieldName === 'isFiling').initialValue : '';
      this.querInfo.receptionStatus = this.topFilterList.find(item => item.fieldName === 'receptionStatus').initialValue
        ? this.topFilterList.find(item => item.fieldName === 'receptionStatus').initialValue
        : '';
      await exportFlowList(this.querInfo)
        .then(response => {
          // console.log(response, 'response');
          exportExcelFile(response.data, '展厅接待列表');
          this.exportLoading = false;
        })
        .catch(err => {
          console.log(err);
        });

      // this.$confirm('是否将Excel表格保存至本地文件夹?', '提示', {
      //     confirmButtonText: '下载',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      // })
      //   .then(() => {
      //     this.querInfo.customerName = this.topFilterList.find(item => item.fieldName === 'customerName').initialValue
      //       ? this.topFilterList.find(item => item.fieldName === 'customerName').initialValue
      //       : '';
      //     this.querInfo.mobilePhone = this.topFilterList.find(item => item.fieldName === 'mobilePhone').initialValue
      //       ? this.topFilterList.find(item => item.fieldName === 'mobilePhone').initialValue
      //       : '';
      //     this.querInfo.storeType = this.topFilterList.find(item => item.fieldName === 'storeType').initialValue ? this.topFilterList.find(item => item.fieldName === 'storeType').initialValue : '';
      //     this.querInfo.arriveDateStart = this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[0]
      //       ? this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[0]
      //       : '';
      //     this.querInfo.arriveDateEnd = this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[1]
      //       ? this.topFilterList.find(item => item.fieldName === 'arriveDateStart|arriveDateEnd').initialValue[1]
      //       : '';
      //     this.querInfo.consultantName = this.topFilterList.find(item => item.fieldName === 'consultantName').initialValue
      //       ? this.topFilterList.find(item => item.fieldName === 'consultantName').initialValue
      //       : '';
      //     this.querInfo.isValid = this.topFilterList.find(item => item.fieldName === 'isValid').initialValue ? this.topFilterList.find(item => item.fieldName === 'isValid').initialValue : '';
      //     this.querInfo.flowType = this.topFilterList.find(item => item.fieldName === 'flowType').initialValue ? this.topFilterList.find(item => item.fieldName === 'flowType').initialValue : '';
      //     this.querInfo.isFiling = this.topFilterList.find(item => item.fieldName === 'isFiling').initialValue ? this.topFilterList.find(item => item.fieldName === 'isFiling').initialValue : '';
      //     this.querInfo.receptionStatus = this.topFilterList.find(item => item.fieldName === 'receptionStatus').initialValue
      //       ? this.topFilterList.find(item => item.fieldName === 'receptionStatus').initialValue
      //       : '';
      //     exportFlowList(this.querInfo)
      //       .then(response => {
      //         console.log(response, 'response');
      //         exportExcelFile(response.data, '展厅接待列表');
      //         this.exportLoading = false;
      //       })
      //       .catch(err => {
      //         console.log(err);
      //       });
      //   })
      //   .catch(() => {
      //     console.log('456');
      //     this.$message({
      //       type: 'info',
      //       message: '已取消'
      //     });
      //   });
    },
    //编辑
    editHandle(row) {
      console.log(row);
      this.handleType = 'edit';
      this.formData = row;
      this.title = '编辑客流';
      this.visible = true;
      this.isShow = false;
    },
    //建档
    addHandleTable(row) {
      console.log(row, '建档');
      // this.visible = true
      this.isShow = true;
      this.title = '建档';
      let data = {
        // customerName:row.consultantCode,
        customerName: row.customerName,
        gender: row.gender,
        mobilePhone: row.mobilePhone,
        consultant: row.consultantName,
        // consultantCode:row.consultantCode,
        consultantCode: row.receptionConsultantName,
        remark: row.remark,
        id: row.id,
        orgId: row.orgId
      };
      console.log(data, 'data');
      this.formData = data;
      // this.$router.push({path:'/potenCus/customer/potenCusManage/index',query:{...row}})
      // this.handleType='exhibitionAdd'
      // this.formData = row;

      // this.visible = true;
    },
    //不建档
    noAddHandleTable(row) {
      console.log(row);
      this.$confirm('该客户已留手机号，确定不建档?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          //走请求
          let params = {
            id: row.id,
            operation: 2
          };
          updateDisposeStatusById(params).then(res => {
            //  console.log(res,"不建档")
            if (res.resultCode == 200) {
              this.$message({
                type: 'success',
                message: '修改成功'
              });
              // 重新加载
              this.fetchParams = { ...this.fetchParams };
              this.reload();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
    },
    // 明细
    detailHandle(row) {
      console.log(row);
      this.handleType = 'show';
      this.formData = row;
      this.title = '客流明细';
      this.visible = true;
      this.isShow = false;
    },
    changeHandle(val) {
      // let params={
      //   isValid:val.isValid,
      //   isFiling:val.isFiling,
      //   flowType:val.flowType,
      //   consultantName: val.consultantName,
      //   customerName: val.customerName,
      //   mobilePhone: val.mobilePhone,
      //   receptionStatus: val.receptionStatus,
      //   storeType: val.storeType,
      //   arriveDateEnd: !Date.parse(val.arriveDateEnd)?"":Date.parse(val.arriveDateEnd),
      //   arriveDateStart:!Date.parse(val.arriveDateStart)?"":Date.parse(val.arriveDateStart),
      //   // "invitationsDate|invitationsDateEnd":'"'+Date.parse(val.invitationsDate)+"|"+Date.parse(val.invitationsDate)+'"'
      // }
      // this.fetchParams = params;
      // this.querInfo=params
      // console.log(this.topFilterList[4].itemList,"this.topFilterList[4]")
      let params = {
        orgId: ''
      };
      let consultantName = this.topFilterList.find(x => x.fieldName === 'consultantName').initialValue;
      this.topFilterList
        .find(x => x.fieldName === 'consultantName')
        .itemList.forEach(x => {
          if (x.value == consultantName) {
            console.log(x.orgId, 'x');
            params.orgId = x.orgId;
          }
        });
      if (val.arriveDateEnd || val.arriveDateStart) {
        if (val.arriveDateEnd.split(' ')) {
          val.arriveDateEnd = val.arriveDateEnd.split(' ')[0];
        }
        if (val.arriveDateStart.split(' ')) {
          val.arriveDateStart = val.arriveDateStart.split(' ')[0];
        }
      }

      this.fetchParams = Object.assign(params, val);
      this.reload();
      this.querInfo = Object.assign(params, val);
    },
    fatherClose(val, type) {
      console.log('andFollow来的', val);
      this.isShow = false;
      this.formData = val.data;
      this.followVisible = true;
    },
    closeHandler_follow(val, type) {
      this.followVisible = val;
      if (type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
        this.reload();
        // this.$refs.Detail.tabRefresh();
      }
    },

    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    closeHandler(val, type) {
      this.visible = val;
      this.isShow = val;
      if (type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
        this.reload();
      }
    }
  }
};
</script>

<style lang="less" scoped>
.duty {
  text-align: right;
  line-height: 40px;
  background: rgb(242, 242, 242);
  padding-left: 10px;
  padding-right: 30px;
}
</style>
